package com.neuedu.controller;


import com.neuedu.common.ResultJson;
import com.neuedu.service.PmsAttrService;
import com.neuedu.service.PmsBrandService;
import com.neuedu.service.PmsCategoryService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 商品表 前端控制器
 * </p>
 *
 * @author 施子安
 * @since 2022-09-28
 */
@RestController
@RequestMapping("/pmsProduct")
public class PmsProductController {
    @Resource
    PmsBrandService pmsBrandService;
    @Resource
    PmsCategoryService pmsCategoryService;
    //属性service
    @Resource
    PmsAttrService pmsAttrService;
    /*
    * 初始化加载两个数据，全部+状态存在
    * */
    @GetMapping("/getInit")
    ResultJson getInit(){
        Map<String, List> map = new HashMap<>();
        map.put("brands",pmsBrandService.getAll());
        map.put("categories",pmsCategoryService.getActive());
        return ResultJson.success(map);
    }
    @GetMapping("/getAttr")
    ResultJson getAttr(Long[] categoryIds){
        return  ResultJson.success(pmsAttrService.getActiveByCategoryIds(categoryIds));
    }
}
